<template>

    <div class="dataTow" ref="dataTow">121132</div>

</template>

<script>
import * as echarts from 'echarts'
import { fenbuNetwork } from '@/network/networks'
export default {
  props: {
    pullTime: Array
  },

  data () {
    return {
      infoclass: [],
      list: []
    }
  },
  methods: {
    initEcharts () {
      const myChart = echarts.init(this.$refs.dataTow)
      const option = {
        title: {
          text: '咨询专业分布',

          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'center',
          bottom: 0,
          data: this.infoclass
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: '50%',
            center: ['50%', '50%'],

            data: this.list,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ],
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        }

      }
      option && myChart.setOption(option)
    },
    getFenBu () {
      fenbuNetwork(this.pullTime).then((res) => {
        this.infoclass = res.data.infoclass
        this.list = res.data.list
        this.initEcharts()
      })
    }
  },
  mounted () {
    this.getFenBu()
  },
  watch: {
    pullTime (val) {
      this.getFenBu()
    }

  }
}
</script>

<style lang="less" scoped>
.dataTow {
  width: 100%;
  height: 600px;
}
</style>
